package com.ejd.web.vo.genl;

import java.util.List;



import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.model.SelectItem;


import com.ejd.service.IApplyService;
import com.ejd.utils.MessageFactory;
import com.ejd.utils.SpringFacesUtil;
import com.ejd.web.bo.impl.Apply;
import com.ejd.web.constant.EjdConstants;
import com.ejd.web.constant.SpringBeanConstants;

@ManagedBean(name="existApply")
@SessionScoped
public class ExistApplyBean implements java.io.Serializable {

	private SelectItem[] applyItems;

	public SelectItem[] getApplyItems() {
		return applyItems;
	}

	public void setApplyItems(SelectItem[] applyItems) {
		this.applyItems = applyItems;
	}
	public ExistApplyBean() {
		
		IApplyService<Apply,Long> applyService = (IApplyService<Apply,Long>)SpringFacesUtil.getSpringBean(SpringBeanConstants.APPLY_SERVICE_BEAN_NAME);
		applyService.setEntityClass(Apply.class);
		applyService.setPKClass(Long.class);
		List<Apply> applys = applyService.getAll();
		SelectItem[] tempApplyItems = new SelectItem[applys.size()];
		if (null != applys && !(applys.isEmpty())) {
			for (int i=0; i< tempApplyItems.length; i++) {
				Apply apply = (Apply) applys.get(i);
				String applyNameN18 = MessageFactory.getMessage(EjdConstants.USER_BUNDLE_NAME,apply.getApplyName(), FacesMessage.SEVERITY_ERROR).getDetail();
				tempApplyItems[i] = new SelectItem(apply.getApplyCode(),applyNameN18);
			}
		}
		this.setApplyItems(tempApplyItems);
	}
}
